import { useState, useEffect } from 'react'
export default function useMouse () {
  const [mouse, setMouse] = useState({ x: 0, y: 0 })
  const move = (e) => {
    setMouse({
      x: e.pageX,
      y: e.pageY
    })
  }
  useEffect(() => {
    document.addEventListener('mousemove', move)

    return () => {
      document.removeEventListener('mousemove', move)
    }
  }, [])

  return mouse
}
